// pages/where/where.js
// 语言包
var chi = require('../../utils/Chinese.js')
var eng = require("../../utils/English.js")
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language:'',
    // 语言包对象
    content: '',
    banner:'../../img/where_banner_03.jpg',
    // 城市
    city_name:'',
    // 店铺列表
    shop_list:[{ id:"0", url:'../../img/shop_03.jpg', name:'店铺名称店铺名称', posi:"上海市长宁区xx路xx号", tel:"021-666666",time:'10:00-22:00'},
    {id:"1",url:'../../img/shop_03.jpg',name:'店铺名称店铺名称', posi:"上海市长宁区路号", tel:"021-666666",time:'10:00-22:00'},{id:"2",url:'../../img/shop_03.jpg',name:'店铺名称店铺名称',posi:"上海市长宁区xx路xx号",tel:"021-666666",time:'10:00-22:00'}]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    this.setData({
      language:app.data.language, 
    })
    var lastLanuage = that.data.language
    if(lastLanuage == 'zh_CN'){
      that.setData({
        content: chi.content,
        // city_name:app.data.city,
      })
      wx.setNavigationBarTitle({
        title: '店铺' 
      })
    }else if(lastLanuage == 'zh_EN'){
      console.log('yingwen')
      console.log('app'+app.data.city)
      that.setData({
        content: eng.content,
        city_name:'Whole Country',
      })
      console.log(this.data.city_name)
      // 修改导航标题
      wx.setNavigationBarTitle({
        title: 'FABBRI Where' 
      })
    }
  },
  // 页面跳转
  toPos:function(){
    console.log('123')
    wx.navigateTo({
      url: '../ctiy/ctiy',
    })
  },
  detail:function(e){
    console.log(e.currentTarget.dataset.id)
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../shop_detail/shop_detail',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this
    this.setData({
      language:app.data.language,
      city_name:app.data.city
    })
    var lastLanuage = that.data.language
    if(lastLanuage == 'zh_CN'){
      that.setData({
        content: chi.content,
        // city_name:app.data.city
      })
      wx.setNavigationBarTitle({
        title: '店铺' 
      })
    }else if(lastLanuage == 'zh_EN'){
      that.setData({
        content: eng.content,
        // city_name:app.data.city
      })
      console.log(this.data.city_name)

      // 修改导航标题
      wx.setNavigationBarTitle({
        title: 'FABBRI Where' 
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})